package com.cn.qgx428.lazydiary.Utils

import android.content.Context
import android.content.pm.PackageManager
import android.support.v4.content.ContextCompat
import java.util.jar.Manifest

/**
 * Created by qinguanxiong on 2018/3/7.
 */
object PermissionUtil {

    fun isAllow(context: Context,permissions: Array<String>): Boolean{
        permissions.forEach {
            if (!hasPermission(context,it))
                return false
        }

        return true
    }

    fun hasPermission(context: Context,permission: String): Boolean{
       return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED
    }

    fun getCameraAndGalleryPemission() =
            arrayOf(android.Manifest.permission.CAMERA,
                    android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
                    android.Manifest.permission.READ_EXTERNAL_STORAGE)

}

